#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool repeatedSubstringPattern(string s) {
    for(int n = 1; n <= s.size()/2; n++){
        if(s.size()%n == 0){
            int c = 0;
            for(int i = 0; i < n; i++){
                int j = i+n;
                while(j < s.size() && s[i] == s[j]){
                    j += n;
                }
                if(j < s.size()){
                    break;
                }else{
                    c++;
                }
            }
            if(c == n) return true;
        }
    }
    return false;
}

int main(){
    // string s = "abcabcabcabc";
    string s = "aabaaba";
    cout << repeatedSubstringPattern(s) << endl;
    return 0;
}
